<?php
require_once('class.ContactList.php');

/** Mirror of the ContactListManager class in java
 */
class ContactListManager {
    // ContactList interface
    /** createList
     * @param $token (string) Authentication token received during login
     * @param $listName (string) The name to attach to the list
     * @return TRUE on success, anything else indicates an error
     */
    public static function createList($token, $listName) {
        // stub
        if(!is_string($token) || !is_string($listName))
            throw new Exception('addList(): invalid data passed');
        // magic happens here
        // ...
        // Probably use CURL or file_get_contents($url) to talk to the server
        // URL for request should look like: "http://192.168.23.76:8080/sclm/list/json/$token/create/$listName"
        // ...
        // parse response
        return TRUE; /* if the response says it worked */
    }
    
    /** addContactsToList
     * @param $token (string) Authentication token received during login
     * @param $listName (string) The name of the list to attach contacts to
     * @param $contactIds (array of strings) An array of IDs of contact records to attach
     * @return FIXME
     */
    public static function addContactsToList($token, $listName, $contactIds) {
        // stub
        if(!is_string($token) || !is_string($listName) || !is_array($contactIds))
            throw new Exception('addContactsToList(): invalid data type passed');
    }
    
    /** removeContactsFromList
     * @param $token (string) Authentication token received during login
     * @param $listName (string) The name of the list to remove contacts from
     * @param $contactIds (array of strings) An array of Ids of contact records to remove
     * @return FIXME
     */
    public static function removeContactsFromList($token, $listName, $contactIds) {
        // stub
        if(!is_string($token) || !is_string($listName) || !is_array($contactIds))
            throw new Exception('removeContactsFromList(): invalid data type passed');
    }
    
    /** removeList
     * @param $token (string) Authentication token received during login
     * @param $listName (string) The name of the list to remove
     * @return FIXME
     */
    public static function removeList($token, $listName) {
        // stub
        if(!is_string($token) || !is_string($listName))
            throw new Exception('removeList(): invalid data type passed');
    }
}
?>
